package com.woniu.product.controller;

import com.woniu.common.util.ResponseData;
import com.woniu.product.pojo.TProductSort;
import com.woniu.product.service.TProductSortService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 杜梅杰
 * @Description
 * @Date 2024/5/20 18:04
 */
@RestController
public class SortController {
    @Autowired
    private TProductSortService sortService;

    /**
     * 查种类
     */
    @GetMapping("/querySorts")
    public ResponseData<TProductSort> querySorts() {
        List<TProductSort> productSorts = sortService.lambdaQuery().eq(TProductSort::getState,1).list();
        return new ResponseData<>().ok(productSorts);
    }

    /**
     * id查种类
     */
    @GetMapping("/getSortName")
    public ResponseData<?> getSortName(Long id) {
        TProductSort sort = sortService.lambdaQuery().eq(TProductSort::getId, id).one();
        return new ResponseData<>().ok(sort);
    }
}
